﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace Pong_Plus
{
    class paleta
    {
        //Declarando os atributos da paleta
        private Texture2D texture;
        public Vector2 position;
        public Rectangle size;
        public Vector2 velocity;

        int points;

        //Contrutor
        public paleta()
        { 
        
        }
        
        //Metodo que move a paleta
        private void Move(Vector2 position,int velocity)
        {

        }

        //Metodo padrão que atualiza
        public void Update(GameWindow janela, KeyboardState key,int player)
        {
            
            #region Manter na Janela

            #endregion 

            //Diferenciando os controles
            if (player == 1)//Jogador 1
            {
                if (Keyboard.GetState().IsKeyDown(Keys.W))
                {
                    if (position.Y > 0)
                    {
                        position.Y -= velocity.Y;
                    }

                }

                if (Keyboard.GetState().IsKeyDown(Keys.S))
                {
                    if (position.Y < (janela.ClientBounds.Height - texture.Height))
                    {
                        position.Y += velocity.Y;
                    }
                }
            }

            if (player == 2)//Jogador 2
            {
                if (Keyboard.GetState().IsKeyDown(Keys.Up))
                {
                    if (position.Y > 0)
                    {
                        position.Y -= velocity.Y;
                    }

                }

                if (Keyboard.GetState().IsKeyDown(Keys.Down))
                {
                    if (position.Y < (janela.ClientBounds.Height - texture.Height))
                    {
                        position.Y += velocity.Y;
                    }
                }
            }

            this.size.X = (int)position.X;
            this.size.Y = (int)position.Y;
        }

 

        public void LoadContent(Texture2D texture)
        {
            //Carrega a textura e inicializa a velocidade
            this.texture = texture;
            this.velocity.Y = 10;
            this.size = texture.Bounds;

            //this.position = new Vector2(
            //janela.ClientBounds.Width / 2
            //- this.size.Width / 2,
            //janela.ClientBounds.Height / 2
            //- this.size.Height / 2);//AQUI

        }

        //Desenha a paleta
        public void Draw(SpriteBatch spriteBatch)
        {
            spriteBatch.Draw(texture, position, Color.White);
        }
    }
}
